from typing import Dict
from typing import List
from enum import IntEnum


class Market(IntEnum):
  NOMARKET = 0
  SZSE = 1
  SSE = 2
  SHFE = 3
  DCE = 4
  CZCE = 5
  CFFEX = 6
  INE = 7
  GFEX = 8

class MinOrDayData:
  datetime: int
  open: float
  high: float
  low: float
  close: float
  settlement: float
  volume: float
  total_turnover: float
  open_interest: float
  average: float
  def __init__(self) -> None:
   self.datetime = 0
   self.open = 0.0
   self.high = 0.0
   self.low = 0.0
   self.close = 0.0
   self.settlement = 0.0
   self.volume = 0.0
   self.total_turnover = 0.0
   self.open_interest = 0.0
   self.average = 0.0


class CodeInfo:
  market: Market
  code: str
  trading_code: str
  name: str
  short_en: str
  listed_date: int
  de_listed_date: int
  trading_hours: List[int]
  contract_multiple: float
  min_tick: float
  def __init__(self) -> None:
   self.code = ""
   self.trading_code = ""
   self.name = ""
   self.short_en = ""
   self.listed_date = 0
   self.de_listed_date = 0
   self.trading_hours = []
   self.contract_multiple = 0.0
   self.min_tick = 0.0


class FQType(IntEnum):
  NA = 0
  FWARD = 1
  BWARD = 2

class FindDataResponse:
  data: List[MinOrDayData]
  def __init__(self) -> None:
   self.data = []


class FindDataRequest:
  market: Market
  code: str
  date: int
  def __init__(self) -> None:
   self.code = ""
   self.date = 0


class MinOrDayDataList:
  datas: List[MinOrDayData]
  def __init__(self) -> None:
   self.datas = []


class SearchCodeRequest:
  keyword: str
  def __init__(self) -> None:
   self.keyword = ""


class SubscribeRTDataRequest:
  market: Market
  code: List[str]
  def __init__(self) -> None:
   self.code = []


class RTDataRequest:
  market: Market
  code: str
  filled_up: bool
  fq: FQType
  fre_num: int
  def __init__(self) -> None:
   self.code = ""
   self.filled_up = False
   self.fre_num = 0


class CodeInfoList:
  datas: List[CodeInfo]
  def __init__(self) -> None:
   self.datas = []


